<?php
namespace Index\Controller;
use Think\Controller;
class RequestController extends Controller {
    
    public function index(){

   
    

    }


    public function getVerify() {

      $config = array(   
      'fontSize'    =>    200,    // 验证码字体大小   
      'length'      =>    4,     // 验证码位数   
      'useNoise'    =>    true, // 关闭验证码杂点
      );

      $v = new \Think\Verify($config);
      $v->entry();
    }


    public function createSqlFile() {
      

    }


   
    function getChannelRqeuest() {
        $url = "http://www.app-echo.com/api/channel/index?page=";
        for ($i=0; $i < 50; $i++) { 
            $count = $i+1;
            $page = $url.$count;
            $data = get_json_info($page);
            $channel = json_decode($data,true);
            $this->getChannel($channel);
        }
    }

    function getChannel($data) {
      $channelArr = $data['channels'];
      for ($i=0; $i <count($channelArr) ; $i++) { 
 
        $channelinfo = $channelArr[$i];
        $model = M('channel');
        $sql = "source_id=".$channelinfo['id'];

        $exist_id = $model->where($sql)->find();
        if (!isset($exist_id)) {
          $data['source_id'] = $channelinfo['id'];
          $data['name'] = $channelinfo['name'];
          $data['pic'] = $channelinfo['pic'];
          $data['user_id'] = $channelinfo['user_id'];
          $data['tag_id'] = $channelinfo['tag_id'];
          $data['type'] = $channelinfo['type'];
          $data['sound_count'] = $channelinfo['sound_count'];
          $data['follow_count'] = $channelinfo['follow_count'];
          $data['share_count'] = $channelinfo['share_count'];
          $data['info'] = $channelinfo['info'];
          $model->add($data);
        }
      }
    }


}